﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Dukous.Search;

namespace Celine.Web.Controllers
{
    public class CustomerController : Controller
    {
        public ISearchService SearchService { get; set; }

        public ActionResult Create(long? id)
        {
            return View();
        }

        public ActionResult Search()
        {
            ISearchContext searchContext = this.SearchService.CreateContext("Customer");
            if (this.Request.RequestType == "POST")
            {
                TryUpdateModel(searchContext, "q");
            }
            else
            {
                searchContext = this.SearchService.CreateContext("Customer")
                    .SetFilter("SerialNumber", "1234")
                    .SetFilter("CreateTime", DateTime.Now.AddDays(-30), DateTime.Now)
                    .SetOrder("SerialNumber")
                    .SetOrder("CreateTime", false);
            }
                

            ISearchResult result = this.SearchService.Search(searchContext);



            return View(result);
        }
    }
}
